# 导入包
import os
import sys
import re

# 执行
if __name__ == '__main__':
    # 接收标准输入
    handle = sys.stdin

    # 循环取每一行
    for line in handle:
        if not line:
            continue

        # 把一行中的元素用空格分割
        friend = line.strip().split(" ")

        owner = friend[0]
        # 自己的朋友们
        owner_friends = friend[1:]

        # 共同的朋友
        for i in range(0, len(owner_friends)):
            for j in range(i + 1, len(owner_friends)):
                # 打印 朋友一朋友二 自己
                # 如 AB C
                print(owner_friends[i] + owner_friends[j] + ' ' + owner)
